// src/hooks/TokenContractContext.tsx
import { createContext, useContext } from 'react';
import { useTokenContract as useTokenContractHook } from './useTokenContract';

const TokenContractContext = createContext<ReturnType<typeof useTokenContractHook> | null>(null);

export const TokenContractProvider = ({ children }: { children: React.ReactNode }) => {
  const contract = useTokenContractHook();
  return (
    <TokenContractContext.Provider value={contract}>
      {children}
    </TokenContractContext.Provider>
  );
};

export const useTokenContract = () => {
  const context = useContext(TokenContractContext);
  if (!context) {
    throw new Error('useTokenContract must be used within a TokenContractProvider');
  }
  return context;
};
